package cn.seecoder.courselearning.controller;

import cn.seecoder.courselearning.po.course.Comments;
import cn.seecoder.courselearning.service.course.CommentsService;
import cn.seecoder.courselearning.vo.ResultVO;
import cn.seecoder.courselearning.vo.course.CommentsVO;
import cn.seecoder.courselearning.vo.course.CourseWareVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/comments")
public class CommentsController {
    @Resource
    CommentsService commentsService;


    @GetMapping("/{courseId}/{commentsId}")
    public CommentsVO getComments(@PathVariable Integer commentsId) {
        return commentsService.getComments(commentsId);
    }

    @GetMapping("/{courseId}")
    public List<CommentsVO> getAllComments(@PathVariable Integer courseId, Integer selectRule) {
        return commentsService.getAllComments(courseId, selectRule);
    }

    @PostMapping("/{courseId}")
    public ResultVO<CommentsVO> createComments(@RequestBody CommentsVO commentsVO) {
        return commentsService.createComments(commentsVO);
    }

    @PostMapping("/delete/{commentsId}")
    public ResultVO<CommentsVO> deleteComments(@PathVariable Integer commentsId){
        return commentsService.deleteComments(commentsId);
    }

}
